package com.spring.data.jpa.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.spring.data.jpa.domain.User;

/**  
 * 用户持久层接口
 **/
public interface UserRepository extends BaseRepository<User, Integer>,UserRepositoryCustom{
	
	/**
	 * Find the user with the given name. This method will be translated into a query using the
	 * {@link javax.persistence.NamedQuery} annotation at the {@link User} class.
	 * 
	 * @param name
	 * @return
	 */
	User findByTheName(String name); 

	/**
	 * Find all users with the given account. This method will be translated into a query by constructing it directly
	 * from the method name as there is no other query declared.
	 * 
	 * @param lastname
	 * @return
	 */
	List<User> findByAccount(String account);

	/**
	 * Returns all users with the given firstname. This method will be translated into a query using the one declared in
	 * the {@link Query} annotation declared one.
	 * 
	 * @param firstname
	 * @return
	 */
	@Query("select u from User u where u.password = ?1")
	List<User> findByPassword(String password);
	
	
	Page<User> findByAccount(String account, Pageable pageable);
	 
}
